from selenium import webdriver
import time

# 打开浏览器
driver = webdriver.Chrome()
# 隐式等待
driver.implicitly_wait(10)
# 打开网页
driver.get('http://www.baidu.com')
# 睡三秒
# time.sleep(3)
# 后退
# driver.back()
# time.sleep(3)
# 前进
# driver.forward()
# time.sleep(3)
# 刷新页面
# driver.refresh()
# 定位搜索框
search_element = driver.find_element_by_id('kw')
# 键盘输入
search_element.send_keys('不良人')
time.sleep(3)
search_element.clear()
time.sleep(3)
search_element.send_keys('南海十三郎')
# 定位提交按钮
# driver.find_element_by_id('su').click()
# 如果是表单，可以用submit()代替click()
search_element.submit()

